import java.util.Random;

public class SimpleThread extends MonteCarlo{
    @Override
    public double monteCarloStandardOption (char CallPutFlag,double S,double X,double T,double r,double b,
                                                   double v,int nSteps,int nSimulations){
        double dt;
        double Sum = 0;
        double drift;
        double vSqrdt;
        int z = 0;
        Random random = new Random();
        dt = T/nSteps;
        drift = ((b - Math.pow(v,2)) / 2) * dt;
        vSqrdt = v * Math.sqrt(dt);
        if (CallPutFlag == 'c'){
            z = 1;
        }
        else if (CallPutFlag == 'p'){
            z = -1;
        }
        for (int i=0;i<nSimulations;i++){
            Sum += MonteCarlo.simulation(z,S,X,drift,vSqrdt,nSteps,random);	
        }
        return Math.exp(-r * T) * (Sum / nSimulations); 
    }
}
